home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / examples / timetest.c < prev   
C/C++ Source or Header  |  2001-05-12  |  696b  |  41 lines

  1.  
  2. /*
  3. **    tek/examples/timetest.c
  4. **    timer accuracy test
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <math.h>
  9. #include <tek/exec.h>
  10.  
  11. int main(int argc, char **argv)
  12. {
  13.     TAPTR basetask;
  14.  
  15.     basetask = TCreateTask(TNULL, TNULL, TNULL);
  16.     if (basetask)
  17.     {
  18.         TTIME t1, t2, t3;
  19.         TFLOAT ex, el;
  20.         
  21.         TFTOTIME(1.234567, &t2)
  22.  
  23.         TTimeQuery(basetask, &t1);
  24.         TTimeDelay(basetask, &t2);
  25.         TTimeQuery(basetask, &t3);
  26.  
  27.         ex = TTIMETOF(&t2);
  28.         el = TTIMETOF(&t3) - TTIMETOF(&t1);
  29.  
  30.         printf("time expected  : %.6fs\n", ex);
  31.         printf("time elapsed   : %.6fs\n", el);
  32.         printf("time difference: %.6fs\n", el-ex);
  33.         printf("time divergence: %.6f%%\n", (el-ex)*100.0f/ex);
  34.         fflush(NULL);
  35.         
  36.         TDestroy(basetask);
  37.     }
  38.     
  39.     return 0;
  40. }
  41.